<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>YDLIDAR SDK: YDLIDAR SDK PACKAGE V1.3.9</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="ydlidar.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">YDLIDAR SDK
   &#160;<span id="projectnumber">V1.3.8</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">YDLIDAR SDK PACKAGE V1.3.9 </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>SDK <a href="https://github.com/yangfuyuan/sdk">test</a> application for YDLIDAR</p>
<p>Visit EAI Website for more details about <a href="http://www.ydlidar.com/">YDLIDAR</a> .</p>
<h1>How to build YDLIDAR SDK samples </h1>
<p>$ git clone <a href="https://github.com/yangfuyuan/sdk">https://github.com/yangfuyuan/sdk</a> $ cd sdk $ git checkout master $ cd .. $ mkdir build $ cd build $ cmake ../sdk $ make ###linux $ vs open Project.sln ###windows</p>
<h1>How to run YDLIDAR SDK samples </h1>
<p>$ cd samples</p>
<p>linux: </p><pre class="fragment">$ ./ydlidar_test
$Lidar[ydlidar7] detected, whether to select current radar(yes/no)?:yes
0. 115200
1. 128000
2. 153600
3. 230400
4. 512000
$Please enter the lidar serial baud rate:2
0. false
1. true
$Please enter the lidar intensity:1
</pre><p>windows: </p><pre class="fragment">$ ydlidar_test.exe
$Lidar[ydlidar7] detected, whether to select current radar(yes/no)?:yes
0. 115200
1. 128000
2. 153600
3. 230400
4. 512000
$Please enter the lidar serial baud rate:2
0. false
1. true
$Please enter the lidar intensity:1
</pre><p>You should see YDLIDAR's scan result in the console: </p><pre class="fragment">[YDLidar]: YDLidar running correctly ! The health status is good
[YDLIDAR] Connection established in [/dev/ttyUSB0]:
Firmware version: 1.2.0
Hardware version: 1
Model: S4
Serial: 2018091100006004
[YDLidar]: [YDLIDAR INFO] Current Sampling Rate : 4K
[YDLidar]: set EXPOSURE MODEL SUCCESS!!!
[YDLidar]: [YDLIDAR INFO] Now YDLIDAR is scanning ......

[YDLidar]: Scan received[1543834103116861000]: 498 ranges
[YDLidar]: Scan received[1543834103241414000]: 497 ranges
[YDLidar]: Scan received[1543834103468167000]: 497 ranges
[YDLidar]: Scan received[1543834103592417000]: 494 ranges
</pre><h1>Lidar point data structure </h1>
<p>data structure: </p><pre class="fragment">struct node_info {
    uint8_t    sync_flag;
    uint16_t   sync_quality;//!信号质量
    uint16_t   angle_q6_checkbit; //!测距点角度
    uint16_t   distance_q2; //! 当前测距点距离
    uint64_t   stamp; //! 时间戳
    uint8_t    scan_frequence;//! 特定版本此值才有效,无效值是0, 当前扫描频率current_frequence = scan_frequence/10.0
} __attribute__((packed)) ;
</pre><p>example: </p><pre class="fragment">if(data[i].scan_frequence != 0) {
    current_frequence = data[i].scan_frequence/10.0;
}

current_time_stamp = data[i].stamp;

 if(m_isMultipleRate) {
    current_distance = (float)data[i].distance_q2/2000.f;
}else {
    current_distance = (float)data[i].distance_q2/4000.f;
}

current_angle = ((data[i].angle_q6_checkbit&gt;&gt;LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT)/64.0f);

current_intensity = (float)(data[i].sync_quality &gt;&gt; LIDAR_RESP_MEASUREMENT_QUALITY_SHIFT);

###note:current_frequence = data[0].scan_frequence/10.0.

###if the current_frequence value equals zero, it is an invalid value.
</pre><p>code: </p><pre class="fragment">    void ParseScan(node_info* data, const size_t&amp; size) {

        double current_frequence, current_distance, current_angle, current_intensity;

        uint64_t current_time_stamp;

        for (size_t i = 0; i &lt; size; i++ ) {

            if( data[i].scan_frequence != 0) {

                current_frequence =  data[i].scan_frequence;//or current_frequence = data[0].scan_frequence

            }

     if(m_isMultipleRate) {
        current_distance = (float)data[i].distance_q2/2000.f;
    }else {
        current_distance = (float)data[i].distance_q2/4000.f;
    }

            current_angle = ((data[i].angle_q6_checkbit&gt;&gt;LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT)/64.0f);//LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT equals 8

            current_intensity = (float)(data[i].sync_quality &gt;&gt; LIDAR_RESP_MEASUREMENT_QUALITY_SHIFT);

        }

        if (current_frequence != 0 ) {

            printf("current lidar scan frequency: %f\n", current_frequence);

        } else {

            printf("Current lidar does not support return scan frequency\n");

        }
    }
</pre><h1>Upgrade Log </h1>
<p>2018-12-3 version:1.3.9</p>
<p>1.Optimized interface.</p>
<p>2.Getting Radar Port Lists.</p>
<p>2018-05-23 version:1.3.4</p>
<p>1.add automatic reconnection if there is an exception</p>
<p>2.add serial file lock.</p>
<p>2018-05-14 version:1.3.3</p>
<p>1.add the heart function constraint.</p>
<p>2.add packet type with scan frequency support.</p>
<p>2018-04-16 version:1.3.2</p>
<p>1.add multithreading support.</p>
<p>2018-04-16 version:1.3.1</p>
<p>1.Compensate for each laser point timestamp. </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
